package net.simflow.swf.analyzer.gui;

import org.eclipse.swt.widgets.Display;

public class ScienceWorkflowAnalyzer {

	private NetworkParserGUI parserGUI;
	private NetworkAnalyzerGUI analyzeWholeNetworkGUI;
	private NetworkAnalyzerGUI analyzeServiceNetworkGUI;

	public static void main(String args[]) {
		try {
			ScienceWorkflowAnalyzer main = new ScienceWorkflowAnalyzer();
			Display display = Display.getDefault();
			NetworkAnalyzerGUI analyzeWholeNetworkGUI = new NetworkAnalyzerGUI(
					display, main, NetworkAnalyzerGUI.STYLE_WHOLE_NETWORK);
			NetworkAnalyzerGUI analyzeServiceNetworkGUI = new NetworkAnalyzerGUI(
					display, main, NetworkAnalyzerGUI.STYLE_SERVICE_NETWORK);
			NetworkParserGUI parserGUI = new NetworkParserGUI(display, main);
			main.setAnalyzeWholeNetworkGUI(analyzeWholeNetworkGUI);
			main.setAnalyzeServiceNetworkGUI(analyzeServiceNetworkGUI);
			main.setParserGUI(parserGUI);
			parserGUI.open();
			parserGUI.layout();
			analyzeWholeNetworkGUI.open();
			analyzeWholeNetworkGUI.layout();
			analyzeServiceNetworkGUI.open();
			analyzeServiceNetworkGUI.layout();
			parserGUI.setFocus();
			while (!analyzeServiceNetworkGUI.isDisposed()
					&& !analyzeWholeNetworkGUI.isDisposed()
					&& !parserGUI.isDisposed()) {
				if (!display.readAndDispatch()) {
					display.sleep();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public NetworkParserGUI getParserGUI() {
		return parserGUI;
	}

	public void setParserGUI(NetworkParserGUI parserGUI) {
		this.parserGUI = parserGUI;
	}

	public NetworkAnalyzerGUI getAnalyzeWholeNetworkGUI() {
		return analyzeWholeNetworkGUI;
	}

	public void setAnalyzeWholeNetworkGUI(
			NetworkAnalyzerGUI analyzeWholeNetworkGUI) {
		this.analyzeWholeNetworkGUI = analyzeWholeNetworkGUI;
	}

	public NetworkAnalyzerGUI getAnalyzeServiceNetworkGUI() {
		return analyzeServiceNetworkGUI;
	}

	public void setAnalyzeServiceNetworkGUI(
			NetworkAnalyzerGUI analyzeServiceNetworkGUI) {
		this.analyzeServiceNetworkGUI = analyzeServiceNetworkGUI;
	}

	public void dispose() {
		if (this.parserGUI != null) {
			while (!this.parserGUI.isDisposed()) {
				this.parserGUI.dispose();
			}
		}
		if (this.analyzeWholeNetworkGUI != null) {
			while (!this.analyzeWholeNetworkGUI.isDisposed()) {
				this.analyzeWholeNetworkGUI.dispose();
			}
		}
		if (this.analyzeServiceNetworkGUI != null) {
			while (!this.analyzeServiceNetworkGUI.isDisposed()) {
				this.analyzeServiceNetworkGUI.dispose();
			}
		}
	}

}
